/*
 * This file is part of the Carpet AMS Addition project, licensed under the
 * GNU Lesser General Public License v3.0
 *
 * Copyright (C) 2024 A Minecraft Server and contributors
 *
 * Carpet AMS Addition is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Carpet AMS Addition is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
 */

package club.mcams.carpet.logging;

import carpet.logging.HUDLogger;
import carpet.logging.LoggerRegistry;

import club.mcams.carpet.logging.logger.ServerRuntimeHUDLogger;

import java.lang.reflect.Field;

public class AmsCarpetLoggerRegistry {
    public static boolean __serverRuntime;

    public static void registerLoggers() {
        LoggerRegistry.registerLogger(ServerRuntimeHUDLogger.NAME, standardHUDLogger(ServerRuntimeHUDLogger.NAME, null, null));
    }

    public static HUDLogger standardHUDLogger(String logName, String def, String [] options) {
        //#if MC<11700
        //$$ return new HUDLogger(getLoggerField(logName), logName, def, options);
        //#else
        return new HUDLogger(getLoggerField(logName), logName, def, options, false);
        //#endif
    }

    public static Field getLoggerField(String logName) {
        try {
            return AmsCarpetLoggerRegistry.class.getField("__" + logName);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException();
        }
    }
}